<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 管理系统大布局 - Layui</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">


        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
<form class="layui-form" >
    <div class="layui-form-item">
        <label class="layui-form-label">个人体温</label>
        <div class="layui-input-block">
            <input type="radio" name="temperature"  th:each="c:${dict['temperature']}"
                   th:value="${c.dictKey}" th:title="${c.dictValue}" checked=true>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否有下列情况？</label>
        <div class="layui-input-block">
            <input type="checkbox" name="physicalCondition" th:each="c:${dict['physical_condition']}"
                   th:value="${c.dictKey}" th:title="${c.dictValue}">

        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">近期动向</label>
        <div class="layui-input-block">
            <input type="radio" name="travel"  th:each="c:${dict['travel']}"
                   th:value="${c.dictKey}" th:title="${c.dictValue}">

        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">近期行程描述</label>
        <div class="layui-input-block">
            <textarea name="travelDescription" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

        </div>

    </div>

<script src="/layui/layui.js"></script>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $ = layui.jquery;
            var arr_box = [];
            $('input[type=checkbox]:checked').each(function() {
                arr_box.push($(this).val());
            });
            //数组
            data.field["physicalCondition"] = arr_box.join(",")
            // ajax 传输数据
            $.ajax({
                url:"/report/add",
                type:"POST",
                contentType: "application/json; charset=utf-8",
                data:JSON.stringify(data.field),
                dataType:'json',
                success:function(result){
                    layer.alert("添加成功", {icon: 6},function (index1) {
                        layer.close(index1);
                        location.reload()
                    });
                }
            });
            return false;
        });
    });
</script>
</body>
</html>